#ifndef NOTIFIER_H
#define NOTIFIER_H

#include <QPixmap>
#include <QPointer>
#include <QRect>
#include <QThread>
#include <QTimer>

class Notification;
class NotificationsMover;
class NotificationDisplayer;


class Notifier : public QObject
{
    Q_OBJECT
public:
    explicit Notifier (QWidget* parent = 0);
    ~Notifier();

    enum DisplayMode { NotificationMode, MessageBoxMode };
    enum MessageType { Hint, Information, Warning, Critical };
    DisplayMode currentDisplayMode() const;

public slots:
    void showMessage (MessageType type, const QString& title, const QString& message);
    void showCritical (const QString& title, const QString& message);
    void showHint (const QString& title, const QString& message);
    void showInformation (const QString& title, const QString& message);
    void showWarning (const QString& title, const QString& message);
    void setDisplayMode (DisplayMode m_displayMode);

private:
    void addNotification (Notifier::MessageType type, const QString& title, const QString& message);
    void addTraditionalNotification (Notifier::MessageType type, const QString& title, const QString& message);
    bool tryShow (Notification* notification);
    QRect checkAvailableGeometry();
    void showNotification (Notification* notification, const QRect& availableGeometry);
    void checkQueuedNotifications();
    const QList<Notification*>& getNotificationsList();

    QWidget* parentWidget;
    QList<Notification*> notifications;
    QList<Notification*> queuedNotifications;
    QList<NotificationDisplayer*> notificationDisplayers;
    QPointer<NotificationsMover> notificationsMover;
    bool removeWidgetLater;
    bool widgetFadingOut;
    bool widgetsWaiting;
    DisplayMode m_displayMode;
    int imageSize;
    QPixmap backgroundImage;
    QPixmap hintImage;
    QPixmap informationImage;
    QPixmap warningImage;
    QPixmap criticalImage;

private slots:
    void fadingOutStarted (const int& height);
    void removeWidget();
    void removeDisplayer();
    void removeMover();

signals:
    void movingStarted();
    void movingEnded();
    void proceed();
    void quitRequest();
};


#endif // NOTIFIER_H
